//
//  ModelUtil.m
//  student
//
//  Created by JCai on 2018/9/7.
//  Copyright © 2018年 haiger. All rights reserved.
//

#import "ModelUtil.h"

@implementation ModelUtil

+ (NSInteger)changeToInteger:(id)result
{
    NSInteger tempInt = 0;
    if(result == nil) {
        return tempInt;
    }
    else if([result isEqual:[NSNull null]]) {
        return tempInt;
    }
    
    tempInt = [result integerValue];
    return tempInt;
}

+ (NSString *)changeToString:(id)result
{
    NSString *tempString = @"";
    if(tempString == nil) {
        return tempString;
    }
    else if([result isEqual:[NSNull null]]) {
        return tempString;
    }
    tempString = result;
    return tempString;
}

#pragma mark - 获取当前的时间
+ (NSString *)getCurrentTimes
{
    NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
    // ----------设置你想要的格式,hh与HH的区别:分别表示12小时制,24小时制
    [formatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
    //现在时间,你可以输出来看下是什么格式
    NSDate *datenow = [NSDate date];
    //----------将nsdate按formatter格式转成nsstring
    NSString *currentTimeString = [formatter stringFromDate:datenow];
    NSLog(@"currentTimeString =  %@",currentTimeString);
    return currentTimeString;
}
@end
